<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>注册页面</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Pragma" content="no-cache">
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
    <link href="${basePath}/singlewindows/css/base.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/singlewindows/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/resources/css/shouye.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/resources/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/resources/css/portal.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<script>
    function goToStep2() {
        $.post("${basePath}/verify/verifyCode?r" + Math.random(), {code: $("#loginCapche").val()}, function (data) {
            if (data) {
                $.post("${basePath}/reg/verifyMail?r" + Math.random(), {
                    mail: $("#email").val(),
                    code: $("#loginCapche").val()
                }, function (data) {
                    if (data.indexOf("success") == 0) {
                        location.href = "${basePath}/reg/validMail?mail=" + $("#email").val() + "&mailKey=" + data.substring(7);
                    } else {
                        alert(data);
                    }
                });
            } else {
                alert("验证码输入错误,请重新输入");
                doChangeValidateCode(document.getElementById("verifyCodeImg"));
            }
        });
    }
</script>
<%@include file="/WEB-INF/pages/common/header.jsp" %>
<div class="main-content-container">
    <div class="regist-main">
        <div class="regist-flowbar flowbar-step1"></div>
        <div class="regist-content">
            <div class="regist-email-verify">
                <div class="regist-had-account">
                    <p class="account-txt">若您已账号，可直接登录。<a href="javascript:;"
                                                          onclick="window.top.location.href='javascript:alert(\'尚未添加\')'"
                                                          class="account-login">马上登录</a></p>
                </div>
                <div class="regist-form">
                    <form id="form_data">
                        <input type="hidden" name="userVo.registerSource" value="8">

                        <div class="clearfix regist-form-controller">
                            <label class="controller-label"><span class="required">*</span>电子邮箱</label>

                            <div class="controller-inp J-controllerInp">
                                <input type="text" name="email" id="email" class="inp-regist">
                            </div>
                        </div>
                        <div class="clearfix regist-form-controller">
                            <label class="controller-label"><span class="required">*</span>验证码</label>

                            <div class="controller-inp J-controllerInp">
                                <input type="text" data-required="true" maxlength="4" minlength="4"
                                       data-required-message="请输入验证码" placeholder="请输入验证码"
                                       name="loginCapche" id="loginCapche"
                                       class="inp inp-regist inp-email-vcode">
                                <img id="verifyCodeImg" alt="如果看不清楚,请点击换一张图片" height="32" width="80"
                                     style="vertical-align: middle; margin-left: 10px;"
                                     onclick="javascript:doChangeValidateCode(this)">
                                <script language="javascript">
                                    function doChangeValidateCode(imgEle) {
                                        imgEle.src = "${basePath}/verify/generateCode?r=" + Math.random();
                                    }
                                    doChangeValidateCode(document.getElementById("verifyCodeImg"));
                                </script>
                            </div>
                        </div>

                        <div class="regist-form-submit">
                            <input type="submit" value="下一步" class="regist-submit-btn"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("#form_data").validate({
            debug: false, //false表示验证通过后不要自动提交表单
            onkeyup: false, //表示关闭按键松开时候监听验证
            rules: {
                email: {
                    required: true,
                    email: true
                }
            },
            messages: { //自定义错误信息，默认为英文，除了在这里配置以为，还可以通过配置文件进行配置
                email: {
                    required: "请输入邮箱地址",
                    email: "请输入正确的邮箱地址"
                }
            },
            //验证通过可以在这里做你想做的事情
            submitHandler: function () {
                goToStep2();
            }
        });
    });
</script>
</body>
</html>
